/**
 *
 */
package com.angel.io.validators.impl;

import com.angel.common.helpers.AnnotationHelper;
import com.angel.common.helpers.ReflectionHelper;
import com.angel.io.annotations.ColumnRow;
import com.angel.io.annotations.RowProcessorCommand;
import com.angel.io.exceptions.RowProcessorCommandValidatorException;
import com.angel.io.validators.RowProcessorCommandValidator;

/**
 * @author William
 *
 */
public class InjectObjectPrimitiveTypeRowProcessorAnnotationValidator implements RowProcessorCommandValidator{

	public void validate(Class<?> importRowCommandClass) throws RowProcessorCommandValidatorException {
		boolean hasAnnotation = AnnotationHelper.hasAnnotation(importRowCommandClass, RowProcessorCommand.class);
		if(hasAnnotation){
			RowProcessorCommand rowProcessorCommand = AnnotationHelper.getAnnotation(importRowCommandClass, RowProcessorCommand.class);
			for(ColumnRow cr: rowProcessorCommand.columnsRow()){
				if(!ReflectionHelper.isAJavaPrimitiveClass(cr.type())){
					throw new RowProcessorCommandValidatorException("Column row name [" + cr.columnName() + "] must be of a primitive type [" + cr.type() + "].");
				}
			}
		}
	}


}
